<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="/WEB-INF/tlds/spring.tld"%>
  <%

String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String loginid = request.getParameter("loginid");
Cookie[] cookies=request.getCookies(); //读出用户硬盘上的Cookie，并将所有的Cookie放到一个cookie对象数组里面
Cookie sCookie=null; 
String svalue=null; 
String sname=null; 
String cookieName = null;
String cookiepwd = null; 
if(null != cookies){
	for(int i=0;i<cookies.length;i++){    //用一个循环语句遍历刚才建立的Cookie对象数组
	sCookie=cookies[i];   //取出数组中的一个Cookie对象 
	sname=sCookie.getName(); //取得这个Cookie的名字
	svalue=sCookie.getValue(); //取得这个Cookie的内容
	if("hmtcmname".equals(sname)){
		cookieName =  svalue;
	} 
	if("hmtcmpwd".equals(sname)){
		cookiepwd =  svalue;
	} 
	}
}
boolean flag = false;
if(null == cookieName){ 
    cookieName = (String)request.getAttribute("username");
}else{
	flag = true;
}
if(null!= loginid && !"".equals(loginid)){
    cookieName = loginid;
}  
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title><spring:message code="sys.name" /></title> 

<script  src="<%=basePath %>common/javascript/common.js"></script>
<script  src="<%=basePath %>common/javascript/check.js"></script>
<link rel="stylesheet" type="text/css" href="<%=basePath %>app/skins/1/css/layout.css">
<link rel="stylesheet" type="text/css" href="<%=basePath %>app/skins/1/css/bootstrap.css">

 
<% 
  String info = (String)request.getAttribute("alert");
  if(null == info)
     info = "";
  String userName = (String)request.getAttribute("username");
  if(null == userName){
     if(null != cookieName){
     	userName = cookieName;
     }else{
     	userName = "";
     }
  }
  session.invalidate();
   
%>
<script language=JavaScript>
 <!--
if(self != top) top.location.href = window.location.href;
//-->
function checkform()
{
if(isNull(document.LoginForm.UserName.value)){
  alert("请输入用户名～！");
  document.all.UserName.focus();
  return false;
}
if(isNull(document.LoginForm.Password.value)){
  alert("请输入密码～！");
  document.all.Password.focus();
  return false;
}
return true;
}
function isNull(pvalue)
 {
   var RegularExp=/^\s*$/;
   if(RegularExp.test(pvalue))
   {
     return true;
   }
   return false;
 }
function submitPage(){ 
    var LoginForm = document.forms[0];
    if(checkform()){
       LoginForm.submit();
    }
	
}
function isEntry(e){
     if(document.all)e = event;
     if(e.keyCode==13) {
             submitPage();
     };
}
function resetinput(){
    document.getElementById("UserName").value='';
        document.getElementById("Password").value='';
    
}
</script>
</head>
<body class="login_body">
<div class="login_parent">
<form name="LoginForm" action="<%=basePath %>logon.do"  method="post"> 
 
        <p>
            用户名<input name="UserName" id="UserName" type="text" class="name" value="<%=cookieName==null?"":cookieName %>"/><br />
            密　码<input name="Password" id="Password" type="password" class="pass" value=""/><br />
           <span><input name="rememberme" type="checkbox"  value="1" <%if(flag){out.println(" checked");} %>/> 记住用户名 </span> 
           </p> 
            <p><input onClick="submitPage();" type="button"  class="btn btn-primary"  value="登录"/>
            <input name="" type="button" onclick="resetinput();" class="btn" value="重置" /> 
            <span><font color=red><strong><%=info %></strong></font></span></p>
    </form> 
    <div class="copy_right"><spring:message code="sys.copyright" /><strong><font color=red> </font></div>
</div>
</body>
</html>
